import httpUtil from '../utils/request'

export function dsPage(ns,ds,page,limit){
    const params = {
        ns,
        ds,
        page,
        limit,
    }
    return httpUtil({
        url: '/ds/page',
        method: 'get',
        params: params
    })
}

export function dsList(ns,ds){
    const params = {
        ns,
        ds
    }
    return httpUtil({
        url: '/ds/list',
        method: 'get',
        params: params
    })
}

export function dsInfo(ns,ds){
    const params = {
        ns,
        ds
    }
    return httpUtil({
        url: '/ds/info',
        method: 'get',
        params: params
    })
}

export function dsDel(ns,dss){
    const data = {
        ns,
        dss
    }
    return httpUtil({
        url: '/ds/del',
        method: 'post',
        data: data
    })
}

export function dsAdd(data){
    return httpUtil({
        url: '/ds/add',
        method: 'post',
        data: data
    })
}

export function dsUpdate(data){
    return httpUtil({
        url: '/ds/update',
        method: 'post',
        data: data
    })
}

export function dsTestConnection(form){
    const data = {
        ns: form.ns,
        dbType: form.dbType,
        ds: form.ds,
        host: form.host,
        port: form.port,
        username: form.username,
        password: form.password,
        dbName: form.dbName
      }
    return httpUtil({
        url: '/ds/testConnect',
        method: 'post',
        data: data
    })
}

export function dsClone(form){
    const data = {
        sourceNs: form.sourceNs,
        targetNs: form.targetNs,
        bizType: form.bizType,
        dataCloneScope: form.dataCloneScope,
        cloneType: form.cloneType,
        sourceInfos: form.sourceInfos
      }
    return httpUtil({
        url: '/ds/clone',
        method: 'post',
        data: data
    })
}

